package com.heima.wemedia.controller;

import com.heima.common.aliyun.GreenImageUrlScan;
import com.heima.common.aliyun.GreenTextScan;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Map;

@RestController
@Slf4j
public class Testcontroller1 {

    @Autowired
    private GreenTextScan textScan;
    @Autowired
    private GreenImageUrlScan urlScan;

    @GetMapping("/test/testText")
    public String testText(@RequestParam(name = "str")String string){

        Map<String, String> map = null;
        try {
            map = textScan.greenTextScan(string);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("map={}",map);
        return "success";
    }

    @GetMapping("/test/testImage")
    public String testImage(){

        String url = "https://p5.itc.cn/images01/20220621/09464426f35344bcbae05e1cb071ffdd.jpeg";

        try {
            Map<String, String> map = urlScan.imageScan(Arrays.asList(url));
            log.info("map={}",map);
        }catch (Exception e){
            e.printStackTrace();
        }

        return "success";
    }
}
